#include <bits/stdc++.h>
using namespace std;
struct car{
    int pos, st, ad;
};
car a[100500];
int p[100500];
bool cr[100];
bool del[100];
vector <int> vv[100];

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin >> T;
    while(T--){
        int n,m,l,v;
        cin >> n >> m >> l >> v;
        bool flag = true;
        for(int i = 1; i <= n; i++){
            cin >> a[i].pos >> a[i].st >> a[i].ad;
            if(a[i].ad != 0){
                flag = false;
            }
        }
        for(int i = 1; i <= m; i++){
            cin >> p[i];
        }
        sort(p+1,p+1+m);
        if(n <= 20 && m <= 20){
            memset(cr,0,sizeof(cr));
            for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                    if(p[j] < a[i].pos){
                        continue;
                    }
                    int k = a[i].st*a[i].st+2*a[i].ad*(p[j]-a[i].pos);
                    if(k < 0){
                        break;
                    }
                    if(k > v*v){
                       cr[i] = 1;
                       vv[j].push_back(i);
                    }
                }
            }
            int cnt = 0;
            for(int i = 1; i <= n; i++){
                if(cr[i]) {
                    cnt++;
                }
            }
            cout << cnt << " ";
            int mx = 0;
            for(int i = 0; i < (1<<m); i++){
                memset(del,0,sizeof(del));
                int num = 0;
                for(int j = 0; j < m; j++){
                    if((i & (1<<j))){
                        for(int k = 0; k < vv[j+1].size(); k++){
                            del[vv[j+1][k]] = true;
                        }
                    } else{
                        num++;
                    }
                }
                bool flag = true;
                for(int i = 1; i <= n; i++){
                    if(cr[i] && !del[i]){
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    mx = max(mx, num);
                }
            }
            cout << mx << endl;
        } else{
            cout << n << " " << 0 << endl;
        }
    }
    return 0;
}
